package com.itheima.reggie.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public R<String> exceptionHandler(Exception ex){
        ex.printStackTrace();
        return R.error("服务器无法给出响应,请稍后重试");
        }

    @ExceptionHandler(MyException.class)
    public R<String> exceptionHandler(MyException ex){
        ex.printStackTrace();
        return R.error(ex.getMessage());
    }
    }



